//tip.js
import gmprotip from '@/components/gmprotip.vue';
import Vue from 'vue'

export function gmprotips(option) {
  let mobileTipComponent = Vue.extend(gmprotip);
  let instance = new mobileTipComponent().$mount();
  Object.assign(instance, option);
  document.body.appendChild(instance.$el);
  setTimeout(() => {
    if(instance.$el){
        instance.$el.style.opacity='0';
        setTimeout(function(){
            instance.$el.remove();
        },600)
    }
  },1200)
}

['success', 'info', 'error'].forEach(type => {
    gmprotips[type] = options => {
    if (typeof options === 'string') {
      options = {
        msg: options
      };
    }
    options.type = type;
    return gmprotips(options);
  };
});